package com.lqian.paging;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class PageHelper {
    static List<User> userList1 = new ArrayList<>();
    public static void main(String[] args) {

        userList1.add(new User(1, "小文", "123456", 16, 1, 20000d));
        userList1.add(new User(2, "老季", "123456", 22, 1, 100000d));
        userList1.add(new User(3, "怪咖", "123456", 13, 1, 89557d));
        userList1.add(new User(4, "小六", "123456", 26, 1, 78000d));
        userList1.add(new User(5, "小刘", "123456", 46, 1, 58000d));


        List<User> users = pageUser(2, 2);
        for (User user:users) {
            System.out.println(user);
        }
    }


    public static List<User> pageUser(int pageNo,int pageSize){
        int skip = (pageNo -1)*pageSize;
        System.out.println(skip);
        return userList1.stream()
//                .sorted(((o1, o2) -> o2.getAge()- o1.getAge()))
                .skip(skip)
                .limit(pageSize)
                .collect(Collectors.toList());
    };



}
